package com.taoz.usercenter.model.response;

import com.taoz.usercenter.exception.BusinessError;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class BaseResponse<T> {
    private String code;
    private String message;
    private T data;

    public static <K> BaseResponse<K> success(K data) {
        return new BaseResponse<>("000", "success", data);
    }

    public static BaseResponse error(BusinessError businessError) {
        return new BaseResponse(businessError.getCode(), businessError.getMessage(), null);
    }
}
